package com.cy;

public class Test12 {
    public static void main(String[] args) {

        for(int i = 0;i<4;i++){
            new MyTicket().start();
        }

    }
}


class MyTicket extends Thread{
    static int tickets=100;

    public void run(){
        while(true){
            synchronized(MyTicket.class){
                if(tickets>0){
                    try {
                        Thread.sleep(10);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(super.getName()+"=="+tickets--);
                }else{
                    break;
                }
            }
        }
    }
}